From 92877a1f9ab2370e39887cb74c7f7552b17aa214 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Mon, 24 Sep 2007 21:41:46 +0100 Subject: [PATCH] x86: Auto-probe the serial port baud rate if 'com1' or 'com2' is specified as a Xen console target. Avoids need for 'com1=' or 'com2=' command-line option in some cases. Signed-off-by: Keir Fraser --- xen/drivers/char/console.c | 15 +++++++++++++++ xen/drivers/char/ns16550.c | 18 +++++++++--------- xen/include/asm-x86/config.h | 2 +- xen/include/xen/console.h | 1 + 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 7d52a4c3ca..e4acd802b4 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -592,6 +592,21 @@ void __init console_endboot(void) switch_serial_input(); } +int console_has(const char *device) +{ + char *p; + + for ( p = opt_console; p != NULL; p = strchr(p, ',') ) + { + if ( *p == ',' ) + p++; + if ( strncmp(p, device, strlen(device)) == 0 ) + return 1; + } + + return 0; +} + void console_start_log_everything(void) { atomic_inc(&print_everything); diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c index 4b37656270..8a67f54489 100644 --- a/xen/drivers/char/ns16550.c +++ b/xen/drivers/char/ns16550.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include @@ -368,15 +369,14 @@ void __init ns16550_init(int index, struct ns16550_defaults *defaults) if ( (index < 0) || (index > 1) ) return; - if ( defaults != NULL ) - { - uart->baud = defaults->baud; - uart->data_bits = defaults->data_bits; - uart->parity = parse_parity_char(defaults->parity); - uart->stop_bits = defaults->stop_bits; - uart->irq = defaults->irq; - uart->io_base = defaults->io_base; - } + uart->baud = (defaults->baud ? : + console_has((index == 0) ? "com1" : "com2") + ? BAUD_AUTO : 0); + uart->data_bits = defaults->data_bits; + uart->parity = parse_parity_char(defaults->parity); + uart->stop_bits = defaults->stop_bits; + uart->irq = defaults->irq; + uart->io_base = defaults->io_base; ns16550_parse_port_config(uart, (index == 0) ? opt_com1 : opt_com2); } diff --git a/xen/include/asm-x86/config.h b/xen/include/asm-x86/config.h index a9bfc7076e..698868fc74 100644 --- a/xen/include/asm-x86/config.h +++ b/xen/include/asm-x86/config.h @@ -45,7 +45,7 @@ #define HZ 100 -#define OPT_CONSOLE_STR "com1,vga" +#define OPT_CONSOLE_STR "vga" #ifdef MAX_PHYS_CPUS #define NR_CPUS MAX_PHYS_CPUS diff --git a/xen/include/xen/console.h b/xen/include/xen/console.h index d6c0510281..7c786ab5df 100644 --- a/xen/include/xen/console.h +++ b/xen/include/xen/console.h @@ -17,6 +17,7 @@ long read_console_ring(XEN_GUEST_HANDLE(char), u32 *, int); void init_console(void); void console_endboot(void); +int console_has(const char *device); int fill_console_start_info(struct dom0_vga_console_info *); -- 2.30.2